<extend name="Base:main" />
<block name="script">
	<link rel="stylesheet" href="__PUBLIC__/seller/css/validform.css" />
	<script src="__PUBLIC__/seller/js/Validform_v5.3.2.js"></script>
</block>
<block name="content">
<div class="tpl-content-wrapper">
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">商品管理</a></li>
                <li class="am-active">商品列表</li>
            </ol>
            <div class="tpl-portlet-components">
               
                <div class="tpl-block">
                    <div class="am-g">
                        <div class="am-u-sm-12 am-u-md-2">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <button type="button" class="am-btn am-btn-default am-btn-success"><span class="am-icon-plus"></span> <a href="{:U('add')}" >新增商品</a></button>
<!--                                    <button type="button" class="am-btn am-btn-default am-btn-secondary"><span class="am-icon-save"></span> 保存</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-warning"><span class="am-icon-archive"></span> 审核</button>
                                    <button type="button" class="am-btn am-btn-default am-btn-danger"><span class="am-icon-trash-o"></span> 删除</button>-->
                                </div>
                            </div>
                        </div>
                        	<style>
								.wz_dx input,.wz_dx label,.wz_dx select{ font-size:14px !important; font-weight:100; }
							</style>
                          <form class="am-form" action="" method="get">
                               <div class="am-u-sm-12 am-u-md-5 wz_dx">
                                   
                                  <label class=" am-form-label">商品名称</label> <span style="display: inline-block;"><input type="text"  name="keyword" value="{$sh.keyword}"  class=" am-form-field"></span>
                                  <label class=" am-form-label">&nbsp;&nbsp;&nbsp;EN13码</label> <span style="display: inline-block;"><input type="text" name="sku" value="{$sh.earn13}" class=" am-form-field"></span>
                                </div>
                                <div class="am-u-sm-12 am-u-md-2 wz_dx">
                                    <div class="am-form-group">
                                        <select id='show_type' name="show_type" >
                                            <option value="0">所有商品</option>
                                            <option value="1">共享商品</option>
                                            <option value="2">我发布的商品</option>
                                        </select>
                                    </div>
                                </div>
                             
                             
                                <div class="am-u-sm-12 am-u-md-3">
                                    <div class="am-input-group am-input-group-sm">
                                         <button type="submit" class="btn btn-purple btn-sm">
                                            <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                            Search
                                        </button>
                                    </div>
                                </div>
                          </form>
                    </div>
					<style>
						.shai_cs{ width:100%; border-top:1px dashed #ccc;border-left:1px dashed #ccc;border-right:1px dashed #ccc;}
						.shai_cs table{ width:100%; font-size:14px;}
						.shai_cs table td.spfl_1{ width:160px; background:#efefef; text-indent:2em; vertical-align:text-top; line-height:40px;}
						.shai_cs table td.spfl_2 a{ padding:2px 10px; display:inline-block; margin:5px 0px 5px 10px; }
						.shai_cs table td.spfl_2 a.active{ background:red; color:#fff;}
						.shai_cs table td.spfl_1,.shai_cs table td.spfl_2{ border-bottom:1px dashed #ccc; }
					</style>
                    <div class="am-g">
						<div class="shai_cs">
							<table>
                            	<tr>
                                	<td class="spfl_1">商品分类</td>
                                    <td class="spfl_2"><a href="{:U('Goods/index')}" <empty name="goods_type_value">class="active"</empty>>全部</a><volist name="goods_type" id="vo"><a href="{:U('Goods/index',array('cat_id' => $vo['id']))}" <?php if( $goods_type_value && $goods_type_value[0] == $vo['id'] ) :?>class="active"<?php endif; ?>>{$vo.name}</a></volist></td>
                                </tr>
                                <?php if( count($goods_type_value) >= 1 && $goods_type[$goods_type_value[0]]['list']) : ?>
                                <tr>
                                	<td class="spfl_1"></td>
                                    <td class="spfl_2"><a href="" <?php if( count($goods_type_value) == 1 ) : ?>class="active"<?php endif; ?>>全部</a><?php foreach( $goods_type[$goods_type_value[0]]['list'] as $k => $v ) : ?><a href="{:U('Goods/index',array('cat_id' => $goods_type[$goods_type_value[0]]['id'].'-'.$v['id']))}" <?php if( $goods_type_value[1] == $v['id'] ) :?>class="active"<?php endif; ?>>{$v.name}</a><?php endforeach; ?></td>
                                </tr>
                                <?php endif; ?>
                            </table>
						</div>
					</div>
                    <div class="am-g">
                        <div class="am-u-sm-12">
                          
                                <table class="am-table am-table-striped am-table-hover table-main">
                                    <thead>
                                        <tr>
                                          
                                            <th class="table-check"> <input class="check-all" type="checkbox" value=""></th>
                                            <th width="80px">商品ID</th>
                                            <th class="table-title"  width="260px">商品名称</th>
                                            <th width="150">属性</th>
                                            <th width="150px">类别</th>
                                            <th width="150px">原产地</th>
                                            <th>供货商家</th>
                                            <th class="table-set" width="150">操作</th>
                                        </tr>
                                    </thead>
									<style>
										.supply_lists{ width:100%;}
										.supply_lists dl{ width:100%; float:left; border-bottom:1px dashed #ccc; margin:0px;}
										.supply_lists dl:last-of-type{ border-bottom:none }
										.supply_lists dl dt{ width:100%; line-height:180%; }
										.supply_lists dl dd{ width:49%; line-height:180%;}
										.supply_lists dl dt,.supply_lists dl dd{ float:left;}
										.supply_lists table{ width:100%; margin-bottom:10px;}
										dt+dd { margin:0px; padding:0px; }
										.supply_page{ width:100%; margin-top:10px; text-align:center;}
										.supply_page a{ padding: 2px 9px; display:inline-block; }
										.supply_page a.active{ background:#0e90d2; color:#fff; }
									</style>
                                    <tbody>
                                      <volist name="data['list']" id="val">
                                        <tr>
                                            <td><input class="ids" type="checkbox" name="ids[]" value="{$val['id']}"></td>
                                            <td>{$val.id}</td>
                                            <td><a href="#">{$val.name}</a></td>
                                            <td><?php foreach($val['attribute'] as $k=>$v):?>
                                                      <?php echo $v['name'].':'.$v['data']."</br>";?>
                                            <?php endforeach;?>
                                            </td>
                                            <td>{$val['type_name']}</td>
                                            <td>{$val['place_origin']}</td>
                                            <td>
												<div id="doc-dropdown-justify">
													<div class="am-dropdown" data-am-dropdown="{justify: '#doc-dropdown-justify'}">
														<a class="am-dropdown-toggle" data-type="close" data-id="{$val.id}" id="supply_show_list">已有【{$val.supply_total}】家供应商 <span class="am-icon-caret-down"></span></a>
														<div class="am-dropdown-content">
															<div class="supply_lists">
																<span></span>
																<div style="clear:both"></div>
															</div>
															<gt name="val.supply_total" value="3">
															<?php
																$page_num = ceil( $val['supply_total'] / 3 );
															?>
															<div class="supply_page" style="display:none;">
															<?php for($i=1;$i<=$page_num;$i++ ) :?>
																<a href="javascript:;" data-val="{$i}"  <?php echo $i == 1 ? 'class="active"' : ''; ?>>{$i}</a>
															<?php endfor; ?>
															</div>
															</gt>
														</div>
													</div>
												</div>
											</td>
                                            <td>
												<div class="list_menu_info">
													操作
													<div class="list_menu_nav">
														<dl>
															<dd><a href="{:U('Goods/addOrder' , array('goods_id' => $val['id']))}" ><span class="am-icon-pencil-square-o"></span> 一键购买</a></dd>
															<dd><a href="{:U('Goods/show',array('id' => $val['id']))}" ><span class="am-icon-pencil-square-o"></span> 商品详情</a></dd>
															<dd><a href="{:U('Goods/supplyCommodity' , array('id' => $val['id']))}"><span class="am-icon-pencil-square-o"></span> 我要供货</a></dd>
															<eq name="val.is_distribution" value="0">
															<dd><a href="{:U('Goods/productDistribution' , array('id' => $val['id']))}" title="产品分销" width="650" height="500" menu="load_iframe_url"><span class="am-icon-pencil-square-o"></span> 我要分销</a></dd>
															</eq>
														</dl>
													</div>
												</div>
                                            </td>
                                        </tr>
                                    </volist>
                                    </tbody>
                                </table>
                                <div class="am-cf">

                                    <div class="am-fr">
                                        <ul class="am-pagination tpl-pagination">
                                            {$data['page']}
                                        </ul>
                                    </div>
                                </div>
                                <hr>

                        </div>

                    </div>
                </div>
                <div class="tpl-alert"></div>
            </div>

        </div>
	<script id="supply_list_tempate">
	{{#  $.each(d.data, function(index, item){ }}
		<dl>
			<dt>
			{{ item.shop_name }}
			{{# if( item.stock_status == 1 ) { }}
			<a href="javascript:;" style=" margin-left:5px; width:15px; height:15px; background:url(__PUBLIC__/seller/img/ku.jpg); display:inline-block;vertical-align: middle;"></a>
			{{# } else { }}
			<a href="javascript:;" style=" margin-left:5px; width:15px; height:15px; background:url(__PUBLIC__/seller/img/tu.jpg); display:inline-block;vertical-align: middle;"></a>
			{{# } }}
			</dt>
			<dd style="width:70%;">
				<table>
					<tr>
						<td>代发价：￥{{ item.acting_price }}</td>
						<td>批发价：￥{{ item.wholesale_price }}</td>
					</tr>
					<tr>
						<td>锁库价：￥{{ item.lock_price }}</td>
						<td>库　存：{{ item.stock_num }}</td>
					</tr>
				</table>
			</dd>
			<dd style="width:30%; text-align:right"><a href="{{ item.url }}" class="am-btn am-btn-primary am-btn-xs" title="产品分销锁库" width="700" height="600" menu="load_iframe_url">我要锁库</a></dd>
		</dl>
	{{# }); }}
	</script>
	<!-- {{# if( item.is_buy == 1 ) { }}<a class="am-btn am-btn-default am-btn-xs">已锁库</a>{{# }else { }} {{# } }} -->
    <script>
		$(document).on('click' , 'div.supply_page a',function(){
			var _self = $(this).closest( '.am-dropdown' );
			$(this).parent().find('a.active').removeClass( 'active' );
			$(this).addClass( 'active' );
			_self.find('.supply_lists').html( data_load_template );
			$.get("{:U('Goods/goodsSupplyList')}" , { goods_id : _self.find('#supply_show_list').attr('data-id') , p : $(this).attr('data-val') } , function( data ){
				if( data.status == 1 ) {
					laytpl($('#supply_list_tempate').html() ).render(data , function(html){
						_self.find('.supply_lists').html( html );
						_self.find('.supply_page').show();
					});
				} else {
					_self.find('.supply_lists').html( not_message_template );
				}
			},'json');
		});
		$('a#supply_show_list').click(function(){
			var data_type = $(this).attr('data-type') == 'close' ? 'open' : 'close';
			var data_id = $(this).attr('data-id');
			var _self = $(this).parent();
			$(this).attr( 'data-type' , data_type );
			if( data_type == 'open' ) {
				_self.find('.supply_lists').html( data_load_template );
				$.get("{:U('Goods/goodsSupplyList')}" , { goods_id : data_id} , function( data ){
					if( data.status == 1 ) {
						laytpl($('#supply_list_tempate').html() ).render(data , function(html){
							_self.find('.supply_lists').html( html );
							_self.find('.supply_page').show();
						});
					} else {
						_self.find('.supply_lists').html( not_message_template );
					}
				},'json');
			} else {
				_self.find('a.active').removeClass( 'active' );
				_self.find('.supply_page a').eq(0).addClass( 'active' );
			}
		});
    </script>
    
</block>